home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE09 / SAFELIST / OLDSHAPE.PAS < prev    next >
Pascal/Delphi Source File  |  1996-04-15  |  1KB  |  45 lines

  1. { File OLDSHAPE.PAS -- original Shapes unit }
  2. unit Shapes;
  3. interface
  4. uses Graphics;
  5. type
  6.   {Base class of the shapes to draw}
  7.   TMyShape = class(TObject)
  8.   private
  9.     fSize   : Integer;
  10.     fTop    : Integer;
  11.     fLeft   : Integer;
  12.     fColour : TColor;
  13.   public
  14.     property Size   : Integer read fSize   write fSize;
  15.     property Top    : Integer read fTop    write fTop;
  16.     property Left   : Integer read fLeft   write fLeft;
  17.     property Colour : TColor  read fColour write fColour;
  18.     procedure Draw(Dest : TCanvas); virtual;
  19.   end;
  20.   TCircle = class(TMyShape)
  21.   public
  22.     procedure Draw(Dest : TCanvas); override;
  23.   end;
  24.   TSquare = class(TMyShape)
  25.   public
  26.     procedure Draw(Dest : TCanvas); override;
  27.   end;
  28. implementation
  29. procedure TMyShape.Draw(Dest : TCanvas);
  30. begin
  31.   Dest.Pen.Color   := Colour;
  32.   Dest.Brush.Color := Colour;
  33. end;
  34. procedure TCircle.Draw(Dest : TCanvas);
  35. begin
  36.   inherited Draw(Dest);
  37.   Dest.Ellipse(Left,Top,Left + Size,Top + Size);
  38. end;
  39. procedure TSquare.Draw(Dest : TCanvas);
  40. begin
  41.   inherited Draw(Dest);
  42.   Dest.Rectangle(Left,Top,Left + Size,Top + Size);
  43. end;
  44. end.
  45.